﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using RenAi.Medical.Model;

namespace RenAi.Medical.DAL
{
    public class AnswerDAL
    {
        /// <summary>
        /// 显示回答列表
        /// </summary>
        /// <returns></returns>
        public DataTable GetALLAnswer()
        {
            string str = "select * from  Answer a join Problem b on a.Pid=b.Pid  join Doctor d on a.Doctor_Id=d.Doctor_Id";
            return DBhelper.GetTable(str);
        }
        /// <summary>
        /// 添加回复信息
        /// </summary>
        /// <param name="a"></param>
        /// <returns></returns>
        public int AddAnswer(Answer a)
        {
            string str = string.Format("insert into Answer values('{0}','{1}','{2}','{3}')",a.Acontent,a.Pid,a.Doctor_Id,a.Adate);
            return DBhelper.NonQuery(str);
        }
        /// <summary>
        /// 删除回复信息
        /// </summary>
        /// <param name="Aid"></param>
        /// <returns></returns>
        public int DelAnswer(string Aid)
        {
            string str = string.Format("delete from Answer where Aid='{0}'",Aid);
            return DBhelper.NonQuery(str);
        }
        /// <summary>
        /// 根据编号查询回复信息
        /// </summary>
        /// <param name="Aid"></param>
        /// <returns></returns>
        public DataTable GetAnswer(string Aid)
        {
            string str = string.Format("select * from Answer where Aid='{0}'",Aid);
            return DBhelper.GetTable(str);
        }
        /// <summary>
        /// 修改回复信息
        /// </summary>
        /// <param name="a"></param>
        /// <returns></returns>
        public int UpdAnswer(Answer a)
        {
            string str = string.Format("update Answer set Acontent='{0}',Doctor_Id='{1}' where Aid='{2}'", a.Acontent,a.Doctor_Id,a.Aid);
            return DBhelper.NonQuery(str);
        }
        /// <summary>
        /// 显示医生信息
        /// </summary>
        /// <returns></returns>
        public DataTable ShowDoctor()
        {
            string str = string.Format("select * from Doctor");
            return DBhelper.GetTable(str);
        }
    }
}
